/////////////////////////////////
//线条 渲染
/////////////////////////////////
var target:Transform;
var scrollSpeed:float = 0.5;
var c1:Color = Color.green;
var c2:Color = Color.red;
var mainTex:Texture2D;

private var count:int = 20;
private var lr:LineRenderer;


function Start(){
	lr = gameObject.AddComponent(LineRenderer);
	
	lr.material = new Material(Shader.Find("Particles/Additive"));
	lr.material.mainTexture = mainTex;
	lr.SetColors(c1,c2);
	lr.SetWidth(0.2,0.3);
	lr.SetVertexCount(count);
}
function Update(){
	var ray:Ray = Camera.main.ScreenPointToRay(Vector3(Input.mousePosition.x,Input.mousePosition.y,0));
	var hit:RaycastHit;
	if(Physics.Raycast(ray,hit)){
		var hitPos:Vector3 = hit.point;
		for(var i:int = 0;i<count;i++){
			var factor:float = (i + 1)/ count;
			var pos:Vector3 = Vector3.Lerp(target.position,hitPos,factor);
			lr.SetPosition(i,pos);
		}
	}
	var offset:float = Time.time * scrollSpeed;
	renderer.material.mainTextureOffset = Vector2(offset,0);
}